a=int(input())
# print(a)
c=input().strip().split()
b=[]
d=2
e=""
# print(c)
for i in c:
    if int(i)<=2:
        d=0
    else:
        for j in range(2,int(i)):
            if int(i) % j==0:
                 d=1
                 break
            else:
                 d=0
    if d==1:
        b.append(i)
print(" ".join(map(str,b)))